﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//for editor
using System.Drawing.Design;
using System.Windows.Forms.Design;

namespace WodLib.Controls
{
    public class StateOfBeingEditor : UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }

        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, 
            IServiceProvider provider, object value)
        {
            //end if not editing StateOfBeing
            if (!(value is WodLib.StateOfBeing))
                return value;

            IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(
                typeof(IWindowsFormsEditorService));

            if (editorService != null)
            {
                StateOfBeingEditorForm form = new StateOfBeingEditorForm((WodLib.StateOfBeing)value);
                editorService.ShowDialog(form);
                value = form.NewHealth;
            }
            return value;

        }
    }
}
